//
// Created by Administrator on 2020/11/29.
//

#ifndef MYNDK_VIDEOCHANNEL_H
#define MYNDK_VIDEOCHANNEL_H


#include "BaseChannel.h"
#include "AudioChannel.h"
extern "C" {
#include <libswscale/swscale.h>
};

/**
 * 1、解码
 * 2、播放
 */
typedef void (*RenderFrameCallback)(uint8_t *,int,int,int);
class VideoChannel : public BaseChannel{

public:
    VideoChannel(int id, AVCodecContext* context,AVRational time_base,int fps);
    ~VideoChannel();

    void setAudioChannel(AudioChannel* audioChannel);
    //解码+播放
    void play();
    void decode();

    void render();

    void setRenderFrameCallback(RenderFrameCallback callback);

private:
    pthread_t pid_decode;
    pthread_t pid_render;
    SwsContext *swsContext=0;
    int fps;
    RenderFrameCallback callback;
    AudioChannel *audioChannel=0;
};


#endif //MYNDK_VIDEOCHANNEL_H
